﻿using System;
using System.Collections.Generic;
using System.Data.SQLite;
using System.IO;
using System.Text;
using System.Windows.Forms;

namespace MyBank
{
    public class Bank
    {
        public int Bank_ID;
        public string Bank_Name;
        public List<Bank_Card> bank_cards = new List<Bank_Card>();

        public Bank(int temp_bank_id, string temp_bank_name)
        {
            // 载入银行卡列表
            SQLiteDataReader Card_reader = CurrentAccount.sql.ReadFullTable("Card");
            this.Bank_ID = temp_bank_id;
            this.Bank_Name = temp_bank_name;
            while (Card_reader.Read())
            {
                if(temp_bank_id == Card_reader.GetInt32(Card_reader.GetOrdinal("Bank_ID"))){
                    int Card_ID = Card_reader.GetInt32(Card_reader.GetOrdinal("Card_ID"));
                    string Card_Type = Card_reader.GetString(Card_reader.GetOrdinal("Card_Type"));
                    string Card_Text = Card_reader.GetString(Card_reader.GetOrdinal("Card_Text"));
                    string Card_Name = Card_reader.GetString(Card_reader.GetOrdinal("Card_Name"));
                    bank_cards.Add(new Bank_Card(Card_ID, Card_Type, Card_Text, temp_bank_id, Card_Name));
                    
                }
            }
            
        }
    }
}